<template>
  <van-cell class="article-item" :to="{
    name: 'article',
    params: {
      articleId: article.art_id,
      article
    }
  }">
    <!-- van-multi-ellipsis--l3: vant自带的类，限定行数最大为3，其余隐藏 -->
    <div slot="title" class="title van-multi-ellipsis--l3">{{ article.title }}</div>
    <div slot="label">
      <!-- 三张图片放置 -->
      <div class="cover-wrap" v-if="article.cover.c">
        <div class="cover-wrap-item">
          <van-image class="cover-item" slot="default" width="116" height="73" fit="cover"
            v-for="(img, index) in article.cover.c.images" :key="index" :src="img" />
        </div>
      </div>
      <!-- 底部作者+评论数+时间 -->
      <div v-if="article.cover.b" class="label-wrap2">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}评论</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
      <div v-else class="label-wrap">
        <span>{{ article.aut_name }}</span>
        <span>{{ article.comm_count }}评论</span>
        <span>{{ article.pubdate | relativeTime }}</span>
      </div>
    </div>
    <van-image v-if="article.cover.b" slot="default" class="right-cover" fit="cover"
      :src="article.cover.b.images[0]" />
  </van-cell>
</template>

<script>
export default {
  name: '',
  components: {},
  data () {
    return {}
  },
  props: {
    article: {
      type: Object,
      required: true
    }
  },
  // 计算属性
  computed: {},
  // 监控data中的数据变化
  watch: {},
  methods: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () { },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () { },
  beforeCreate () { }, // 生命周期 - 创建之前
  beforeMount () { }, // 生命周期 - 挂载之前
  beforeUpdate () { }, // 生命周期 - 更新之前
  updated () { }, // 生命周期 - 更新之后
  beforeDestroy () { }, // 生命周期 - 销毁之前
  destroyed () { }, // 生命周期 - 销毁完成
  activated () { } // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style scoped lang='less'>
.article-item {
  .title {
    font-size: 16px;
    color: #3a3a3a;
  }
  /deep/ .van-cell__value {
    flex: unset;
    width: 116px;
    height: 73px;
    margin-left: 12px;
  }
  .right-cover {
    width: 116px;
    height: 73px;
  }
  .cover-wrap {
    padding: 15px 0;
    .cover-wrap-item {
      display: flex;
      .cover-item {
        &:not(:last-child) {
          padding-right: 4px;
        }
        width: 100%;
        height: 73px;
      }
    }
  }
  .label-wrap {
    font-size: 11px;
    color: #b4b4b4;
    span {
      margin-right: 12px;
    }
  }
  .van-cell__title {
    position: relative;
    .label-wrap2 {
      position: absolute;
      bottom: 0;
      font-size: 11px;
      color: #b4b4b4;
      span {
        margin-right: 12px;
      }
    }
  }
}
</style>
